<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绝对定位absolute</title>

    <style>
        /* 父级元素无定位 */
        .father {
            width: 500px;
            height: 500px;
            background-color: skyblue;
        }

        .son {
            position: absolute;
            top: 100px;
            right: 200px;
            width: 200px;
            height: 200px;
            background-color: pink;
        }

        /* 父级元素有定位 */
        .father2 {
            position: relative;
            width: 500px;
            height: 500px;
            background-color: skyblue;
        }

        .son2 {
            position: absolute;
            top: 120px;
            left: 10px;
            width: 200px;
            height: 200px;
            background-color: pink;
        }

        /* 多层嵌套 */
        .yeye {
            position: relative;
            width: 800px;
            height: 800px;
            background-color: springgreen;
        }

        .father3 {
            width: 500px;
            height: 500px;
            background-color: skyblue;
        }

        .son3 {
            position: absolute;
            bottom: 20px;
            left: 10px;
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>

</head>
<body>

    <img src="绝对定位absolute.png" alt="">
    <br><br>

    <h3>父级元素无定位</h3>
    <div class="father">
        父级元素1
        <div class="son">父级元素1无定位</div>
    </div>

    <h3>父级元素有定位</h3>
    <div class="father2">
        父级元素2
        <div class="son2">父级元素2有定位</div>
    </div>

    <h3>多层嵌套级别</h3>
    <div class="yeye">
        最外层
        <div class="father3">
            父级元素3
            <div class="son3">父级元素3有定位</div>
        </div>
    </div>

</body>
</html>